import { request } from '~/api/request'
const isSpecialized = ['KEEPER'].includes(JSON.parse(localStorage.getItem('u')!).roles[0])

const WaitReceiveUrl = isSpecialized
  ? '/api/internal/v1/item/receive/query/special/waitReceiveCaseList'
  : '/api/internal/v1/item/receive/query/curator/waitReceiveCaseList'

const WaitInform = isSpecialized
  ? '/api/internal/v1/item/receive/query/special/waitInformCaseList'
  : '/api/internal/v1/item/receive/query/curator/waitInformCaseList'

const Inform = isSpecialized
  ? '/api/internal/v1/item/receive/query/special/informCaseList'
  : '/api/internal/v1/item/receive/query/curator/informCaseList'

const receiveUrl = isSpecialized
  ? '/api/internal/v1/item/receive/special/receive'
  : '/api/internal/v1/item/receive/curator/receive'

const receivedUrl = isSpecialized
  ? '/api/internal/v1/item/receive/query/special/receiveCaseList'
  : '/api/internal/v1/item/receive/query/curator/receiveCaseList'

const backUrl = isSpecialized
  ? '/api/internal/v1/item/receive/special/giveBack'
  : '/api/internal/v1/item/receive/curator/giveBack'

const informUrl = isSpecialized
  ? '/api/internal/v1/item/receive/special/inform'
  : '/api/internal/v1/item/receive/curator/inform'

export const queryWaitReceiveCaseList = (data: any): any => request('post', WaitReceiveUrl, data)

export const queryWaitInform = (data: any): any => request('post', WaitInform, data)

export const queryInform = (data: any): any => request('post', Inform, data)

export const queryWaitTake = (data: any): any =>
  request('post', '/api/internal/v1/item/deal/query/waitDealConfirmCaseList', data)

export const queryTake = (data: any): any =>
  request('post', '/api/internal/v1/item/deal/query/dealConfirmCaseList', data)

export const queryReceiveCaseList = (data: any): any => request('post', receivedUrl, data)

export const queryCastItems = (data: any): any => request('post', '/api/internal/v1/item/receive/query/castItems', data)

export const queryStorePlaceCaseList = (data: any): any =>
  request('post', '/api/internal/v1/item/receive/query/curator/storePlaceCaseList', data)

export const queryCuratorCastItems = (data: any): any =>
  request('get', '/api/internal/v1/item/receive/query/curator/castItems', data)

export const queryDealCastItems = (data: any): any =>
  request('post', '/api/internal/v1/item/deal/query/castItems', data)

export const handleReceive = (data: any): any => request('post', receiveUrl, data)

export const handleGiveBack = (data: any): any => request('post', backUrl, data)

export const handleUpdateRemark = (data: any): any =>
  request('post', '/api/internal/v1/item/receive/updateRemark', data)

export const handleUpdateWhereabouts = (data: any): any =>
  request('post', '/api/internal/v1/item/receive/special/updateWhereabouts', data)

export const handleCancelInform = (data: any): any =>
  request('post', '/api/internal/v1/item/receive/special/cancelInform', data)

export const handleConfirmInform = (data: any): any => request('post', informUrl, data)

export const handleConfirmDeal = (data: any): any => request('post', '/api/internal/v1/item/receive/confirmDeal', data)
